package gamebase.core;

public abstract class Event extends Thread {
	protected Node sender;
	
	public static final int UP = 1;
	public static final int DOWN = -1;
	public static final int DONE = 0;
	
	private int initialDirection;
	
	/**
	 * Create a new Event object. The new event will by default be sent out immediately.
	 * 
	 * @param sender
	 * @param direction
	 */
	public Event(Node sender, int direction){
		this.sender = sender;
		this.initialDirection = direction;
		start();
	}
	
	/**
	 * Sends the event up or down the tree. Called automatically upon event creation, running in a new thread.
	 */
	public void run(){
		sender.sendEvent(this, initialDirection);
	}
	
	/**
	 * Receive a node as input, do whatever the event is intended to do, and
	 * return an integer telling the node whether to pass the event up or down, or
	 * to stop it.
	 * 
	 * @param input
	 * @return int
	 */
	public abstract int checkNode(Node input);
}
